package analysis;

import java.util.Vector;

import structures.StaticGraph;

public class PatternSearch {
	private static final int SUBGRAPH = 6;
	
	public static void buildFrequencyTable() {
		
	}
	
	
	public static StaticGraph sampleGraph(StaticGraph g) {
		String randomNode = g.getNodes().get((int) (Math.random() * g.size()));
		Vector<String> subgraph = new Vector<String>();
		Vector<String> open = new Vector<String>();
		open.add(randomNode);
		while(subgraph.size() < SUBGRAPH && ! open.isEmpty()) {
			String node = open.remove(0);
			for(int i = 0; i < g.getNbrs(node).size(); i++) {
				String s = g.getNbrs(node).get(i);
				if(! open.contains(s) && ! subgraph.contains(s)) {
					open.add(s);
				}
			}
			subgraph.add(node);
		}
		StaticGraph newGraph = new StaticGraph(g, subgraph);
		return newGraph;
	}
}
